package com.sisy.dubbo_provider;

import com.sisy.common.AccountService;
import com.sisy.common.DubboOrderService;
import com.sisy.common.OrderDO;
import com.sisy.mapper.OrderDealMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

/**
 * @author EJ
 * @date 2021-06-13 17:37
 */
@Service("dubboOrderService")
public class DubboOrderServiceImpl implements DubboOrderService {
    @Autowired
    private OrderDealMapper orderDealMapper;

    @Lazy
    @Autowired
    private AccountService accountService;
    @Override
    public String createOrder(OrderDO orderDO) {
        //扣费
        accountService.debitMoney(orderDO.getUserId(), orderDO.getMoney());
        //创建订单
        orderDealMapper.insertOne(orderDO);
        return "200";
    }
}
